<!doctype html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>发布</title>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<link href="../css/list.css" rel="stylesheet" />
		<script src="../../js/mui.min.js"></script>
		 <script src="../../js/app.js"></script>
		 <link href="../css/style.css" rel="stylesheet" />
		 <link href="../../css/icons-extra.css" rel="stylesheet"/>
		 <link href="../../css/mui.min.css" rel="stylesheet" />
<!--<link rel="stylesheet" href="css/message.css" type="text/css" />-->
		 		<!--<script src="../js/jquery-3.3.1.js"></script>-->
		 		<style type="text/css">
		 			.mui-content{
		 				margin-bottom: 40px;  
		 			}
		 			/*body {font-family: sans-serif;}*/
		 			#show_messagea li{
		 				background: #fff;
		 		/*		padding:5px 5px 0 5px;*/
		 			}
		 			#show_messagea{
		 				background: #FAFAFA;
		 			/*#show_messagea img{
		 				/*background: #FAFAFA;*/
		 				/*padding:5px 5px 0 5px;*/
		 				
		 			}
		 			.mui-media-body{
		 				
		 				/*background: #F3F3F3;*/
		 				/*padding:5px 5px 0 5px;*/
		 				/*border-radius:10px;
		 				font-size: 16px;
		 				line-height:120%;
		 				margin : 0px 2px 2px 5px;*/
		 			}
		 			.p1{
		 				color: #000000;
		 				font-size: 20px;
		 				/*letter-spacing:0.1em;*/
		 				/*text-indent:2em;*/
		 				/*padding:0 0.1em;*/
		 				padding: 3px;
		 			}
		 			.p2{
		 				/*margin : 0px 2px 10px 55px;*/
		 				/*background: #EFEFF4;*/
		 				padding:0 0px 0 62px;
		 				border-radius:5px;
		 			}
table,tr,td,th{

padding: 0;

margin: 0;

}

table{

width: 100%;

border-color: #ccc;

}

table tr{

/*line-height: 30px;*/
/**/
border-color: #ccc;

}

table th,table td{
	 padding: 8px;
border-width: 1px;
 border-style: solid;
 border-color: #999999;
/*text-align: center;*/

/*border-color: #ccc;*/

}

		 			/*tr:nth-child(odd){background:#F0F8FF;}*/
table tr:nth-child(even){
background: #ccc;
}
		 			a{ text-decoration:none;
    color:#222222;}

/*小盒子内容区的样式，display:inline-block：实现 效果*/
#con{
	margin: 1px;
}
#con .pic{ border-radius:1px;float:left; min-height:100px;box-shadow:2px 2px 6px #b5b5b5;line-height:1.2;margin: 5px;padding:2px;}
#con p{
	margin-bottom: 2px;
}
.mui-input-row label{
	padding-right: 5px;
	}
#con h5{padding:1px;margin-top: -2px;border-bottom:1px solid #ddd;}
#con h5 a{text-decoration:none;color:#999;}

</style>
</head>
<body>
	<header class="mui-bar mui-bar-nav">
	    <a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
	    <h1 class="mui-title">项目发布</h1><div class="btn-right" style="margin-top: 10px;">发布</div>
	</header>
<div class="mui-content">
    <form class="mui-input-group" name="myform">
      	    <div class="mui-input-row">
      	        <label>项目名称</label>
      	        <input type="text" id="mingcheng" name="libname" class="mui-input-clear" placeholder="捉妖记(不能重名)">
      	    </div>
      	    <div class="mui-input-row">
      	        <label>项目类型</label>
				   <select id="xiangmuleixing"style="width:65%;">
				  <option value="0">请选择类别</option>
				  <option value="xiangmu">院线电影</option>
				  <option value="ziyuan">网络电影</option>
				  <option value="jishu">网络剧</option>
				  <option value="qita">电视剧</option>
				 </select> 
      	        <!--<input type="text" name="title" class="mui-input-clear" placeholder="北京大唐圣殿影视文化有限公司">-->
      	    </div>
      	    

      	    <div class="mui-input-row">
      	        <label>出品公司</label>
      	        <input type="text" id="chupingongsi" name="libname" class="mui-input-clear" placeholder="北京大唐圣殿影视文化有限公司" >
      	    </div>
      	    <div class="mui-input-row">
      	        <label>项目负责人</label>
      	        <input type="text" id="fuzeren" name="libname" class="mui-input-clear" placeholder="张xx">
      	    </div>
      	    <ul class="mui-table-view" >
			        <li class="mui-table-view-cell mui-collapse"><a class="mui-navigate-right" href="#">
						封面海报<span class="mui-badge mui-badge-primary">上传</span>
					</a>
					<ul class="mui-table-view">
      	    <div class="mui-table-view-cell" id="poster" onclick="pickFile(this.id)" style="max-width:99%;text-align:center;">
    <img  style="margin: 1% 8%;width: 80%;height: auto;"   src="../images/iconfont-tianjia.png" />
</div>
</ul>
        </li></ul>
      	    <ul class="mui-table-view" >
			        <li class="mui-table-view-cell mui-collapse"><a class="mui-navigate-right" href="#">
						支持入股方式<span class="mui-badge mui-badge-primary">多选</span>
					</a>
					<ul class="mui-table-view">
						<li class="mui-table-view-cell" id="rugufangshi">
						<div style="width: 49%;float: left;">
							<label>资源入股</label>
					    <input name="rugufangshi" value="资源" type="checkbox" checked>
					    </div>
					    <div style="width: 49%;float: left;">
							<label>技术入股</label>
					    <input name="rugufangshi"  value="技术" type="checkbox" checked>
					     </div>
					    <div style="width: 49%;float: left;">
							<label>资金入股</label>
					    <input name="rugufangshi" value="资金" type="checkbox" checked>
					    </div>
					    </li>
      </ul>
        </li></ul>
      	    <ul class="mui-table-view" >
			        <li class="mui-table-view-cell mui-collapse"><a class="mui-navigate-right" href="#">
						接受技术类别<span class="mui-badge mui-badge-primary">多选</span>
					</a>
					<ul class="mui-table-view" >
						<li class="mui-table-view-cell" id="jishuleibie">
						<div style="width: 49%;float: left;">
							<label>编剧</label>
					    <input name="jishuleibie" value="编剧" type="checkbox" checked>
					    </div>
					    <div style="width: 49%;float: left;">
							<label>导演</label>
					    <input name="jishuleibie" value="导演" type="checkbox" checked>
					     </div>
					    <div style="width: 49%;float: left;">
							<label>特效</label>
					    <input name="jishuleibie" value="特效" type="checkbox" checked>
					     </div>
					    </li>
                   </ul>
        </li></ul>
      	    <ul class="mui-table-view" >
			        <li class="mui-table-view-cell mui-collapse"><a class="mui-navigate-right" href="#">
						接受资源类别<span class="mui-badge mui-badge-primary">多选</span>
					</a>
					<ul class="mui-table-view" >
						<li class="mui-table-view-cell" id="ziyuanleibie">
						<div style="width: 49%;float: left;">
							<label>器材</label>
					    <input value="器材" type="checkbox" checked>
					    </div>
					    <div style="width: 49%;float: left;">
							<label>设备</label>
					    <input value="设备" type="checkbox" checked>
					     </div>
					    <div style="width: 49%;float: left;">
							<label>车辆</label>
					    <input  value="车辆" type="checkbox" checked>
					     </div>
					    </li>
      </ul>
        </li></ul>
 <!--<div style="padding:15px;">
        <button id='pickDateBtn' type="button" class="mui-btn">选择日期</button>
    </div>-->
      	    <div class="mui-input-row">
      	        <label>预计回报日期</label>
      	        <input type="text"  id='huibaodate' name="libname" onclick="datarow(this)" class="mui-input-clear" placeholder="2019-12-20"style="float:left;width: 30%;" placeholder="1000"><label style="float: left;width: 90px;padding-left: 0;">日</label>
      	    </div>
      	     <div class="mui-input-row">
      	        <label>筹备截至日期</label>
      	        <input type="text"  id='stopdate' name="libname" onclick="datarow(this)" class="mui-input-clear" placeholder="2019-12-20"style="float:left;width: 30%;" placeholder="1000"><label style="float: left;width: 90px;padding-left: 0;">日</label>
      	    </div>
      	    <div class="mui-input-row">
      	        <label>股份数量总数</label>
      	        <input type="text"  id="gufenzongshu"  name="libname" class="mui-input-clear" placeholder="3000"style="float:left;width: 30%;" placeholder="1000"><label style="float: left;width: 90px;padding-left: 0;">份</label>
      	    </div>
      	    <div class="mui-input-row">
      	        <label>每份预估价值</label>
      	        <input type="text" id="gufendanjia" name="libname" class="mui-input-clear" placeholder="100"style="float:left;width: 30%;" placeholder="1000"><label style="float: left;width: 90px;padding-left: 0;">元(人民币)</label>
      	    </div>
      	    <div class="mui-input-row">
      	        <label>保留股份数量</label>
      	        <input type="text" id="baoliugufen" name="libname" class="mui-input-clear" style="float:left;width: 30%;" placeholder="1000"><label style="float: left;width: 90px;padding-left: 0;">份</label>
      	    </div>
      	    <div class="mui-input-row">
      	        <label>故事简介</label></div>
      	        <textarea id="gushijianjie" name="libname" class="mui-input-clear" placeholder="请输入100-500字之间" maxlength="500" type="text" rows="3" cols="30"></textarea>
      	    <!--</div>-->
      	    <div >
      	    <p style="color:red;padding-top: 5px;padding-left: 20px;">* 以上信息提交后不可修改，请慎重填写</p>
      	    <p style="padding-bottom: 5px;padding-left: 20px;">* 项目主创团队/策划案/关联动态可后续追加更新</p></div>
      	</form> <div class="mui-input-row">
      	<button type="button" class="mui-btn mui-btn-blue" style="padding:7px;margin: 1%;width: 98%;font-size: 18;" onclick="tijiao()">提交</button></div>
      </div>
      <!--<div>查看数据详单>>>></div>-->
</body>
<script type="text/javascript">
	// 从相册添加图片文件 
function pickFile(thisid){
	var lasnum=1;//限制选择图片数量
   plus.gallery.pick(
      function(paths){
      	for(i in paths.files){mui.toast(paths.files[i]);
      		var imglist=document.getElementById(thisid).getElementsByTagName("img");//获取图片标签所在位置
			var image = new Image();//压缩图片
			image.src = paths.files[i];    
			image.onload = function(){
			  var img64 = compress(image,1080, 0.7);
			  imglist[0].src = img64;//显示压缩后的图片;
			  localStorage.setItem('img',img64);//图片存入本地数据库
//			  alert('弹出拉'+img64);
			}
//    		localStorage.setItem('img',paths.files[i]);//图片存入本地数据库
//    		imglist[0].src=paths.files[i];//显示图片
      	}},
      function(e){mui.toast('取消了选择');},{multiple:true,maximum:lasnum,system:false,onmaxed:function(){ plus.nativeUI.alert('对不起本次最多只能选择'+lasnum+'张图片'); 
	}}
   );
}

/*
 * 图片压缩
 * img    原始图片
 * maxwh   压缩后的宽高最长边
 * ratio   压缩比率 
 */
 function compress(img_url, maxwh, ratio) {
  //           maxwh=280;//定义压缩图片最大宽高
            var width = img_url.width,
             height = img_url.height,
             scale = width / height; 
             if(height>maxwh && width>maxwh){
               if(width>=height){
                width=maxwh;
                height=width/scale;
               }else{
                height=maxwh;
                width=scale*height;
               }
               }
    var canvas, ctx, img64;       
   canvas = document.createElement('canvas');   
   canvas.width = width;
   canvas.height = height;
   ctx = canvas.getContext("2d");        
   ctx.drawImage(img_url, 0, 0, width, height);
   img64 = canvas.toDataURL("image/jpeg", ratio);
   return img64;
 }
var optbJson={
		"xiangmuleixing":{"院线电影":"院线电影","网络电影":"网络电影","电视剧":"电视剧","网络剧":"网络剧"},
		"rugufangshi":{"资源入股":"资源入股","技术入股":"技术入股","资金入股":"资金入股","其他":"其他"},
		"jishuleibie":{"导演":"导演","制片":"制片","宣传":"宣传","发行":"发行","音乐版权":"音乐版权","演员":"演员","摄影":"摄影","美术":"美术","灯光":"灯光","服装":"服装","化妆":"化妆","造型":"造型","道具":"道具","剪辑":"剪辑","调色":"调色","配音":"配音","包装":"包装","其他":"其他","平面设计":"平面设计"},
		"ziyuanleibie":{"器材":"器材","车辆":"车辆","机房":"机房","产品":"产品","影棚":"影棚","场景":"场景","住宿":"住宿","餐饮":"餐饮","其他":"其他"}
		 };
		 
//var jishuleibie=document.getElementById('jishuleibie');
//var	objrugufangshi = document.getElementById("rugufangshi");
for(var k in optbJson){
var rugufangshiche='';
var	obj = document.getElementById(k);
//	alert(k);
for(var p in optbJson[k]){//遍历json对象的每个key/value对,p为key
if(k=='xiangmuleixing'){
rugufangshiche+='<option name="'+k+'" value="'+p+'">'+optbJson[k][p]+'</option>';	
}else{
rugufangshiche+='<div style="width: 49%;float: left;"><input name="'+k+'" value="'+p+'" type="checkbox" checked><label>'+optbJson[k][p]+'</label></div>';
}
}
obj.innerHTML=rugufangshiche;
}
function tijiao(){
	var sizenum=1;
	if(document.getElementById('gushijianjie').value.length<sizenum){
		alert('故事简介最少需要'+sizenum+'字，请从新提交');
//		return false;
	}
	// 得到页面中所有input	
	var allInputs = document.getElementsByTagName('input');
	var libIds = [];
	// 在所有Input中过滤出type="text" and name="libID"的元素，放到数组libIds中  && allInputs[i].name === 'libname'
//	for (var i = 0; i < allInputs.length; i++) {
//		if (allInputs[i].type === 'text' && allInputs[i].name === 'libname') 
//		{
//			libIds.push(allInputs[i]);	
//			if(allInputs[i].value==''){
//			alert('您有表单未填写，请填写后提交');
////			return false;
//			}
//		}
//	}
			xiangmuleixing_val='';
    		rugufangshi_val ='';
    		jishuleibie_val='';
    		ziyuanleibie_val='';
	for(var kb in optbJson){
			var	objtj = document.getElementsByName(kb);
//  		alert(kb);
	    for(pb in objtj){
//	    	  if(kb=='xiangmuleixing'){xiangmuleixing_val=objtj[pb].value;};
	        if(objtj[pb].checked){
	    	if(kb=='rugufangshi'){rugufangshi_val+=objtj[pb].value+',';};
	    	if(kb=='jishuleibie'){jishuleibie_val+=objtj[pb].value+',';};
	    	if(kb=='ziyuanleibie'){ziyuanleibie_val+=objtj[pb].value+',';};
//	            rugufangshi_val+=objtj[k].value+',';
	    }
    }}
mui.post(home.hos+'/item/user',Object.assign(apptoken,{
		act:'publish',
		title:document.getElementById('mingcheng').value,
		classname:document.getElementById('xiangmuleixing').value,
		produce:document.getElementById('chupingongsi').value,
		head:document.getElementById('fuzeren').value,
		source:rugufangshi_val,
		technology:jishuleibie_val,
		resources:ziyuanleibie_val,
		repaytime:document.getElementById('huibaodate').value,
		deadline:document.getElementById('stopdate').value,
		share:document.getElementById('gufenzongshu').value,
		moneyunit:document.getElementById('gufendanjia').value,
		reserve:document.getElementById('baoliugufen').value,
		content:getFormatCode(document.getElementById('gushijianjie').value),
		poster:document.getElementById('poster').getElementsByTagName("img")[0].src
	}),function(data){
		alert(data);
		if(data!=200){
			plus.ui.toast("发布失败,请重新尝试，错误码".data);
		}else{
				alert("发布成功");
				mui.back();
				var list = plus.webview.currentWebview().opener();
				//触发父页面的自定义事件(refresh),从而进行刷新
				 mui.fire(list, 'refresh');
				//返回true,继续页面关闭逻辑
				return true;
				}
		//服务器返回响应，根据响应结果，分析是否登录成功；

	},'text'
);}
function datarow(data){
	var dDate = new Date();
    //设置当前日期（不设置默认当前日期）
    dDate.setFullYear(2018, 7, 16);
    var minDate = new Date();
    //最小时间
    minDate.setFullYear(2018, 0, 1);
    var maxDate = new Date();
    //最大时间
    maxDate.setFullYear(2035, 11, 31);
    plus.nativeUI.pickDate(function(e) {
        var d = e.date;
        document.getElementById(data.id).value=d.getFullYear()+ "-" + (d.getMonth() + 1) + "-" + d.getDate();
        mui.toast('您选择的日期是:' + d.getFullYear() + "-" + (d.getMonth() + 1) + "-" + d.getDate());
    }, function(e) {
        mui.toast("您没有选择日期");
    }, {
        title: '请选择日期',
        date: dDate,
        minDate: minDate,
        maxDate: maxDate
    });
	
}

function Show_Hidden(trid){
    if(trid.style.display=="block"){
        trid.style.display='none';
    }else{
        trid.style.display='block';
    }
}
function jieshu(){
	alert('您现在要结束项目码');
}
function shangchuan(){
	alert('请上传项目策划案，格式仅限制ppt/pdf/doc/zip,大小不得超过10mb');
}
//alert(val);
//document.getElementById('title').innerHTML=title;
//document.getElementById('neirong').innerHTML=val;

  </script>